import http from '@src/util/http';
import GrayUtil from '@src/util/gray';
/* service */
import { convertQualityInfoRemoteDataToFormQualityInfoFieldValue } from '@service/QualityInfoService.ts'
import { objectDateToTimestamp } from 'pub-bbx-utils';

let de_headUrl = '';
let headUrl = '/api/customer/outside/pc'
let headUrl2 = '/api/elasticsearch/outside/es'
let headUrl3 = '/api/customer'

/**
 * 产品注册字段
 */
export function getRegisterFields() {
  return http.get(`${headUrl3}/outside/register/field/list`);
}

/**
 * 产品注册列表
 * @param {String} params -- 列表入参
 * @returns Promise<>
 */
export function getRegisterList(params) {
  objectDateToTimestamp(params, ['createTimeStart', 'createTimeEnd', 'updateTimeStart', 'updateTimeEnd'])
  return http.post(`${headUrl3}/outside/register/getPageList`, params);
}
/**
 * 产品注册详情
 * @param {String} params -- 详情入参
 * @param {String} params.id -- 产品注册id
 * @returns Promise<>
 */
 export function getRegisterDetail(params) {
  return http.get(`${headUrl3}/outside/register/getOne`, params);
}

/**
 * 保存至客户的列表
 * @param {String} params -- 详情入参
 * @returns Promise<>
 */
 export function getCustomerList(params) {
  return http.get(`${headUrl3}/outside/register/getCustomerList`, params);
}

/**
 * 保存至产品的列表
 * @param {String} params -- 详情入参
 * @returns Promise<>
 */
 export function getProductList(params) {
  return http.get(`${headUrl3}/outside/register/getProductList`, params);
}

/**
 * 产品注册新建
 * @param {String} params -- 产品注册新建
 * @returns Promise<>
 */
 export function registerCreate(params) {
  return http.post(`${headUrl3}/outside/register/create`, params);
}


/**
 * 产品注册编辑
 * @param {String} params -- 产品注册编辑
 * @returns Promise<>
 */
 export function registerUpdate(params) {
  return http.post(`${headUrl3}/outside/register/update`, params);
}

/**
 * 产品注册删除
 * @param {String} params.id -- 产品注册id
 * @returns Promise<>
 */
 export function registerDelete(params) {
  return http.get(`${headUrl3}/outside/register/delete`, params);
}

/**
 * 产品注册动态信息
 * @param {String} params.id -- 产品注册动态信息
 * @returns Promise<>
 */
 export function getRegisterLogList(params) {
  return http.get(`${headUrl3}/outside/register/getRegisterLogList`, params);
}

/**
 * 产品注册确认重复
 * @param {String} params.fieldList -- 待确认字段和值
 * @param {String} params.id -- 产品注册id
 * @returns Promise<>
 */
 export function checkRepeat(params) {
  return http.post(`${headUrl3}/outside/register/checkRepeat`, params);
}

/**
 * 录入产品编码后获取产品信息
 * @param {String} params.registerValue -- 产品注册字段值
 * @returns Promise<>
 */
 export function getProductInfo(params) {
  return http.get(`${headUrl3}/outside/register/getProductInfo`, params);
}

/**
 * 产品注册审核
 * @param {String} params.id -- id
 * @param {String} params.reason -- 原因
 * @param {String} params.registerStatus -- 审核状态 1、审核通过，2、审核拒绝
 * @returns Promise<>
 */
 export function registerAudit(params) {
  return http.post(`${headUrl3}/outside/register/registerAudit`, params);
}

/**
 * 产品注册url
 * @returns Promise<>
 */
 export function registerUrl(params) {
  return http.get(`${headUrl3}/outside/register/url`, params);
}

/**
 * 产品注册审核人员列表
 * @returns Promise<>
 */
 export function registerApproverList(params) {
  return http.get(`/register/approver/list`, params);
}